#!/usr/bin/env python2.5
# encoding: utf-8

class StreamDict(dict):
  def __setitem__(self, key, value):
    global esda
    
    esda.streamsList["height"] += 1
    esda.streamsList.insert(END, key + " (" + value.type + ")")
    esda.setStreamColors(value)
    
    return super(StreamDict, self).__setitem__(key, value)
  
  def __getitem__(self, key):
    if isinstance(key, int):
      label = esda.streamsList.get(key)
      
      return super(StreamDict, self).__getitem__(label[0:label.rindex(' ')])
    else:
      return super(StreamDict, self).__getitem__(key)
  
  def clear(self):
    esda.streamsList.delete(0, END)
    esda.streamsList["height"] = 0
    
    return super(StreamDict, self).clear()
